package com.aba.hos.doc.entity;

import java.util.ArrayList;
import java.util.List;

/**
 * 医生实体类，存储医生信息及负责的病人
 */
public class Doctor {
    private static int nextId = 2000;
    private String adminId;
    private final int id;
    private String name;
    private String specialty;
    private List<Patient> patients;

    public Doctor(String name, String specialty) {
        this.id = nextId++;
        this.name = name;
        this.specialty = specialty;
        this.patients = new ArrayList<>();
        this.adminId = adminId;
    }

    public Doctor(int id,String name, String specialty) {
        this.id = id;
        this.name = name;
        this.specialty = specialty;
        this.patients = new ArrayList<>();
        this.adminId = adminId;
    }

    public String getAdminId() {
        return adminId;
    }

    public void setAdminId(String adminId) {
        this.adminId = adminId;
    }

    // Getters and Setters
    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSpecialty() {
        return specialty;
    }

    public void setSpecialty(String specialty) {
        this.specialty = specialty;
    }

    public List<Patient> getPatients() {
        return patients;
    }

    public void addPatient(Patient patient) {
        if (!patients.contains(patient)) {
            patients.add(patient);
            patient.setAttendingDoctor(this);
        }
    }

    public void removePatient(Patient patient) {
        patients.remove(patient);
        if (patient.getAttendingDoctor() == this) {
            patient.setAttendingDoctor(null);
        }
    }

    @Override
    public String toString() {
        return "Doctor{id=" + id +
                ", name='" + name + '\'' +
                ", specialty='" + specialty + '\'' +
                ", patientsCount=" + patients.size() +
                '}';
    }
}    